package learn.emp03.ex04;

import java.util.*;

abstract class Shape {
    public static final double PI = 3.14;

    public abstract double getPerimeter();

    public abstract double getArea();
}

class Rectangle extends Shape {
    int width;
    int length;

    public Rectangle(int width, int length) {
        this.width = width;
        this.length = length;
    }

    @Override
    public double getPerimeter() {
        return 2 * (width + length);
    }

    @Override
    public double getArea() {
        return width * length;
    }

    @Override
    public String toString() {
        return "Rectangle [width=" + width + ", length=" + length + "]";
    }
}

class Circle extends Shape {
    int radius;

    public Circle(int radius) {
        this.radius = radius;
    }

    @Override
    public double getPerimeter() {
        return 2 * Shape.PI * radius;
    }

    @Override
    public double getArea() {
        return Shape.PI * radius * radius;
    }

    @Override
    public String toString() {
        return "Circle [radius=" + radius + "]";
    }
}

public class Main {
    public static double sumAllArea(Shape[] shapes) {
        double totalArea = 0;
        for (Shape shape : shapes) {
            totalArea += shape.getArea();
        }
        return totalArea;
    }

    public static double sumAllPerimeter(Shape[] shapes) {
        double totalPerimeter = 0;
        for (Shape shape : shapes) {
            totalPerimeter += shape.getPerimeter();
        }
        return totalPerimeter;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        scanner.nextLine();

        Shape[] shapes = new Shape[n];

        for (int i = 0; i < n; i++) {
            String type = scanner.next();
            if (type.equals("rect")) {
                int width = scanner.nextInt();
                int length = scanner.nextInt();
                shapes[i] = new Rectangle(width, length);
            } else if (type.equals("cir")) {
                int radius = scanner.nextInt();
                shapes[i] = new Circle(radius);
            }
            scanner.nextLine();
        }

        double totalPerimeter = sumAllPerimeter(shapes);
        double totalArea = sumAllArea(shapes);

        System.out.println(totalPerimeter);
        System.out.println(totalArea);
        System.out.println(Arrays.toString(shapes));

        for (Shape shape : shapes) {
            System.out.println(shape.getClass() + "," + shape.getClass().getSuperclass());
        }
    }
}